package cn.bs.busuo.content.dao.persist.repository.impl;

import cn.bs.busuo.content.dao.persist.mapper.HotelArticleDetailMapper;
import cn.bs.busuo.content.dao.persist.mapper.HotelArticleMapper;
import cn.bs.busuo.content.dao.persist.repository.HotelArticleRepository;
import cn.bs.busuo.content.pojo.entity.ContentHotelArticle;
import cn.bs.busuo.content.pojo.entity.ContentHotelArticleDetail;
import cn.bs.busuo.content.pojo.vo.ContentHotelArticleListBySortVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: Feng
 * @since: 2023/12/6
 */
@Repository
public class HotelArticleRepositoryImpl implements HotelArticleRepository {
    @Autowired
    private HotelArticleMapper hotelArticleMapper;

    @Autowired
    private HotelArticleDetailMapper hotelArticleDetailMapper;

    //判断文章标题是否存在
    @Override
    public int contentHotelArticleByTitle(String title) {
        int title1 = hotelArticleMapper.contentHotelArticleByTitle(title);
        return title1;
    }

    //添加文章
    @Override
    public int addNewHotelArticle(ContentHotelArticle contentHotelArticle) {
        return hotelArticleMapper.insert(contentHotelArticle);
    }

    //根据酒店文章标题查询Id
    @Override
    public Long selectHotelArticleByTitle(String title) {
        return hotelArticleMapper.selectHotelArticleByTitle(title);
    }

    //添加文章到详情
    @Override
    public int addNewHotelArticleDetail(ContentHotelArticleDetail contentHotelArticleDetail) {
        return hotelArticleDetailMapper.insert(contentHotelArticleDetail);
    }

    //搜索文章
    @Override
    public ContentHotelArticle contentHotelArticleById(Long id) {
        return hotelArticleMapper.selectById(id);
    }

    //根据文章Id查询文章
    @Override
    public int selectHotelArticleById(Long id) {
        return hotelArticleMapper.selectHotelArticleById(id);
    }

    //删除文章,伪删除,只是改为不显示
    @Override
    public int deleteHotelArticle(List<Long> ids) {
        return hotelArticleMapper.updateIsDisplay(ids);
    }


    //设置为推荐文章
    @Override
    public int updateIsRecommend(List<Long> ids, Integer isRecommend) {
        return hotelArticleMapper.updateIsRecommend(ids,isRecommend);
    }

    //设置为不推荐文章
    @Override
    public int updateIsNotRecommend(List<Long> ids, Integer isRecommend) {
        return hotelArticleMapper.updateIsNotRecommend(ids,isRecommend);
    }

    //审核通过文章
    @Override
    public int updateCheckState(List<Long> ids, Integer checkState) {
        return hotelArticleMapper.updateCheckState(ids,checkState);
    }

    //审核不通过文章
    @Override
    public int updateCheckNotState(List<Long> ids, Integer checkState) {
        return hotelArticleMapper.updateCheckNotState(ids,checkState);
    }

    //设置文章排序
    @Override
    public int updateSort(Long id, Integer sort) {
        return hotelArticleMapper.updateSort(id,sort);
    }

    //查看排序文章
    @Override
    public List<ContentHotelArticleListBySortVO> selectListBySort() {
        return hotelArticleMapper.selectListBySort();
    }

    //查看未审核文章
    @Override
    public List<ContentHotelArticle> selectListByCheckState() {
        return hotelArticleMapper.selectListByCheckState();
    }



}
